package adv2;

import java.util.ArrayList;
import java.util.List;

public class ArrTest2 {

	public static void main(String[] args) {
		List li = new ArrayList();

		li.add(new Book("java编程思想", "人民邮电出版社", 230));
		li.add(new Book("c编程思想", "人民邮电出版社", 230));
		li.add(new Book("C++编程思想", "人民邮电出版社", 230));
		li.add(new Book("C#编程思想", "人民邮电出版社", 230));
		li.add(new Book("python编程思想", "人民邮电出版社", 230));
		li.add("html");
		li.set(1, new Book("汇编编程思想", "人民邮电出版社", 230));
		for (int i = 0; i < li.size(); i++) {
			if (!(li.get(i) instanceof Book)) {
				System.out.println(li.get(i));
				continue;
			}

			Book b = (Book) li.get(i);
			System.out.println(b);
		}
		// indexOf：查找对象的位置
		Book b = new Book("python编程思想", null, -1);
		int weizhi = li.indexOf(b);

		System.out.println("这本书在集合的" + weizhi + "处");

		Book b3 = new Book("C#编程思想", 0);
		boolean isIn = li.contains(b3);
		System.out.println(isIn);
		// li.remove(b3);
		System.out.println(li.remove(b3));
		System.out.println(li);
		// for (int i = 0; i < li.size(); i++) {
		// Book b2 = (Book) li.get(i);
		// if(b2.getName().equals(b.getName))
		// }
	}
}
